<template>
  <!--客户潜在等级-->
  <el-dialog
    :close-on-click-modal="false"
    title="客户潜在等级修改"
    :visible.sync="dialogVisible18"
    width="420px">
    <el-form :model="dengjiForm" size="mini" label-width="120px" ref="dengjiForm"  :rules="rules18">
      <el-form-item label="潜在等级：" prop="customerPotentialId">
        <el-select v-model.number="dengjiForm.customerPotentialId" class="input-width" style="width:195px" placeholder="请选择" clearable >
          <el-option
            v-for="item in customerPotentialList"
            :key="item.customerPotentialId"
            :label="item.customerPotentialValue"
            :value="item.customerPotentialId">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="原因：" prop="potentialReason">
        <el-input v-model="dengjiForm.potentialReason" :autosize="{ minRows: 2, maxRows: 6}" type="textarea"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
          <el-button @click="handleClose18">取 消</el-button>
          <el-button type="primary" @click="handleConfirm18" :loading="btnLoading18">确 定</el-button>
      </span>
  </el-dialog>
</template>
<script>
import {customerPotential,ajaxEditDengji} from '@/api/partner'
import {customerNewCycleConfirm} from '@/api/company'
import {validatePhone} from '@/utils/validate';
import {formatDate} from '@/utils/date';
import store from '@/store'
import { mapGetters } from 'vuex'




export default {
  name: "index",
  data(){
    return {
      customerPotentialList:[],
      dialogVisible18:false,
      btnLoading18:false,
      dengjiForm:{
        customerId:'',
        customerPotentialId:'',
        potentialReason:''
      },
      rules18:{
        customerPotentialId:[{required: true, message: '请选择潜在等级', trigger: 'change'},],
        potentialReason:[{required: true, message: '请输入修改潜在等级理由', trigger: 'blur'},],
      },

    }
  },
  computed: {
    ...mapGetters([
      'name',
      'mobile',
      'userId'
    ]),
  },
  components : {

  },
  created() {

  },
  filters: {

  },
  methods:{
    //获取潜在等级
    getCustomerPotential(){
      customerPotential().then((res)=>{
        this.customerPotentialList = res;
      })
    },
    //显示客户潜在等级弹窗
    showDengjiForm(item){
      this.dialogVisible18 = true;
      this.dengjiForm.customerId = item.customerId;
      this.dengjiForm.customerPotentialId = item.customerPotentialId;
      this.dengjiForm.potentialReason = '';
      this.getCustomerPotential();
    },

    //关闭客户潜在等级弹窗
    handleClose18(){
      this.dialogVisible18 = false;
      this.btnLoading18 = false;
      this.dengjiForm.customerId = '';
      this.dengjiForm.customerPotentialId = '';
      this.dengjiForm.potentialReason = '';
    },

    //确认客户潜在等级
    handleConfirm18(){
      this.$refs.dengjiForm.validate((valid) => {
        if (valid) {
          ajaxEditDengji(this.dengjiForm).then((res)=>{
            if(typeof (res) == 'string' && res != ''){
              this.$message({
                type: 'warning',
                message: res,
                duration:6000
              });
            }else{
              this.$message({
                type: 'success',
                message: '操作成功！'
              });
            }

            this.btnLoading18 = false;
            this.handleClose18();
            this.$emit('getList')
          }).catch(()=>{
            this.btnLoading18 = false;
          })
        }
      })
    },

  },
}
</script>

<style  lang="scss">

</style>
